import request from '@/utils/request'

const repository = 'b/MpFollowerController'
const mpApi = {
    tongbuFans: repository + '/tongbuFans',
    saveTag: repository + '/saveTag',
    addFansTag: repository + '/addFansTag',
    tagCount: repository + '/tagCount',
    pageFans: repository + '/pageFans',
    addFansRemark: repository + '/addFansRemark',
    deleteModel: repository + '/delete',
    checkRunningSync: repository + '/checkRunningSync'
}

export function checkRunningSync (parameter) {
    return request({
        url: mpApi.checkRunningSync,
        method: 'get',
        params: parameter
    })
}

export function tongbuFans (mpId, gzhUserId) {
    return request({
        url: mpApi.tongbuFans,
        method: 'get',
        params: {
            mpId,
            gzhUserId
        }
    })
}

export function saveTag (parameter) {
    return request({
        url: mpApi.saveTag,
        method: 'POST',
        data: parameter
    })
}

export function addFansTag (gzhUserId, fanId, mpId, tagList) {
    return request({
        url: mpApi.addFansTag,
        method: 'POST',
        data: {
            tags: tagList,
            fansId: fanId,
            gzhUserId: gzhUserId,
            mpId: mpId
        }
    })
}

export function tagCount (mpId, gzhUserId) {
    return request({
        url: mpApi.tagCount,
        method: 'get',
        params: {
            mpId,
            gzhUserId
        }
    })
}

export function pageFans (query, { gzhUserId, mpId, nickname, tagId }) {
    return request({
        url: mpApi.pageFans,
        params: {
            query: JSON.stringify(query),
            search: JSON.stringify({
                keyword: nickname,
                k2: mpId,
                k3: tagId,
                k5: gzhUserId
            })
        }
    })
}

export function addFansRemark (fansId, remark, gzhUserId) {
    return request({
        url: mpApi.addFansRemark,
        params: {
            fansId: fansId,
            remark: remark,
            gzhUserId: gzhUserId
        }
    })
}

export function deleteModel (id, gzhUserId) {
    return request({
        url: mpApi.deleteModel,
        method: 'get',
        params: {
            id, gzhUserId
        }
    })
}

export default {
    tongbuFans,
    saveTag,
    addFansTag,
    tagCount,
    pageFans,
    addFansRemark,
    deleteModel,
    checkRunningSync

}
